﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace XmlDSigEx
{
    class X509DataWriter
    {
        private X509Certificate2 _certificate;

        public X509DataWriter(X509Certificate2 certificate)
        {
            _certificate = certificate;
        }

        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement("X509Data", XmlSigner.NS_XMLDSIG);
            writer.WriteStartElement("X509Certificate", XmlSigner.NS_XMLDSIG);
            writer.WriteString(Convert.ToBase64String(_certificate.Export(X509ContentType.Cert)));
            writer.WriteEndElement();
            writer.WriteEndElement();
        }
    }
}
